#include "../include/head.h"

int pthread_func(taskNode_t *get_node,pthread_mutex_t *mtx_clientInfo,MYSQL *mysql,int *epfd,Client_info *client_info)
{
    int netfd= get_node->netfd;
    int user_id = get_node->user_id;
    int now_path_id = get_node->now_path_id;
    int args_len = strlen(get_node->args);
    MSG_TYPE type = get_node->type;
    int epfd_s = *epfd;
   //  printf("子线程接受到的netfd = %d\n", netfd);
   //  printf("子线程接受到的user_id = %d\n", user_id);
   //  printf("子线程接受到的now_path_id = %d\n", now_path_id);
   //  printf("子线程接受到的type = %d\n", get_node->type);
   //  printf("子线程接受到的args =  :%s\n", get_node->args);
   //  printf("子线程接收到的epfd = %d\n", epfd_s);

    if (type == C_OP_CD)
    {
        server_cd(mysql,args_len, get_node->args,netfd, client_info, mtx_clientInfo, now_path_id,user_id);
    }
    else if(type == C_OP_LS)
    {
        server_ls(mysql,args_len, get_node->args,netfd, client_info, mtx_clientInfo, now_path_id,user_id);
      //   printf("ls pthread_func\n");
    }
    // else if(type == C_OP_PWD)
    // {
    //     server_pwd(sharedRequest,serverDir, netfd);
    // }
    else if(type == C_OP_MKDIR)
    {
        server_mkdir(mysql,args_len, get_node->args,netfd, client_info, mtx_clientInfo, now_path_id,user_id);
    }

     else if(type == C_OP_RMDIR)
     {
        server_rmdir(mysql,args_len, get_node->args,netfd, client_info, mtx_clientInfo, now_path_id,user_id);
     }
     else if(type == C_OP_REMOVE)
     {
        server_rmfile(mysql,args_len, get_node->args,netfd, client_info, mtx_clientInfo, now_path_id,user_id);
     }
     else if(type == C_OP_REMOVE)
     {
     }
     else if(type == C_OP_PUTS_QUERY)
     {
        server_puts_query(mysql,args_len,get_node->args,netfd,client_info,mtx_clientInfo,now_path_id,user_id);
     }
     else if(type == C_OP_PUTS_BEGIN)
     {
        server_puts_begin(mysql,&epfd_s,args_len,get_node->args,netfd,client_info,mtx_clientInfo,now_path_id,user_id);
     }
     else if(type == C_OP_GETS_QUERY)
     {
        server_gets_query(mysql,args_len,get_node->args,netfd,client_info,mtx_clientInfo,now_path_id,user_id);
     }
     else if(type == C_OP_GETS_BEGIN)
     {
        server_gets_begin(mysql,&epfd_s,args_len,get_node->args,netfd,client_info,mtx_clientInfo,now_path_id,user_id);
     }
    return 1;
}
